﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Basic_sprite_code
{
    class StoryHelper:Sprite
    {
        public bool playingGame;
        public bool mouseDown;
        public bool gameWon;
        public int frame;

        public StoryHelper(DarkLordsApprentice g, Vector2 position)
            : base(g, "Story1", position, new Vector2(0, 0))
        {
            playingGame = false;
            mouseDown = false;
            gameWon = false;
            frame = 1;
        }

        public override void Update(GameTime gameTime)
        {
            MouseState m = Mouse.GetState();

            if (!playingGame)
            {
                if (m.LeftButton == ButtonState.Pressed)
                {
                    mouseDown = true;
                }

                if (mouseDown)
                {
                    if (m.LeftButton == ButtonState.Released)
                    {
                        frame++;
                        if (frame == 3)
                        {
                            playingGame = true;
                        }
                        if (frame == 4)
                        {
                            frame = 1;
                            gameWon = false;
                        }
                        mouseDown = false;
                    }
                }
            }

            switch (frame)
            {
                case 1:
                    image = game.Content.Load<Texture2D>("Story1");
                    break;
                case 2:
                    image = game.Content.Load<Texture2D>("Story2");
                    break;
                case 3:
                    if (!playingGame)
                    {
                        frame++;
                    }
                    else
                    {
                        image = game.Content.Load<Texture2D>("StoryBlank");
                    }
                    break;
                case 4:
                    if (gameWon)
                    {
                        image = game.Content.Load<Texture2D>("Story3");
                    }
                    else
                    {
                        image = game.Content.Load<Texture2D>("Story4");
                    }
                    break;
                default:
                    break;
            }

            
            base.Update(gameTime);
        }
    }
}
